% arara: pdflatex
% arara: makeindex: {style: latexindent.ist}
% arara: bibtex
% arara: pdflatex if changed (toFile('latexindent.aux')) || changed (toFile('latexindent.ind')) 
% arara: pdflatex if changed (toFile('latexindent.aux')) 
% arara: pdflatex if changed (toFile('latexindent.aux')) 
\documentclass[10pt]{article}
%   This program is free software: you can redistribute it and/or modify
%   it under the terms of the GNU General Public License as published by
%   the Free Software Foundation, either version 3 of the License, or
%   (at your option) any later version.
%
%   This program is distributed in the hope that it will be useful,
%   but WITHOUT ANY WARRANTY; without even the implied warranty of
%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
%   GNU General Public License for more details.
%
%   See <http://www.gnu.org/licenses/>.
\usepackage[left=4.5cm,right=2.5cm,showframe=false,
 top=2cm,bottom=1.5cm,marginparsep=2cm]{geometry} % page setup
\usepackage{lmodern}
\usepackage{parskip}                                 % paragraph skips
\usepackage{booktabs}                                % beautiful tables
\usepackage{listings}                                % nice verbatim environments
\usepackage{titlesec}                                % customize headings
\usepackage{titletoc}                                % customize headings
\usepackage{multicol}
\usepackage{changepage}                              % adjust width of page
\usepackage{fancyhdr}                                % headers & footers
\usepackage{fontawesome}
\usepackage[sc,format=hang,font=small]{caption}      % captions
\usepackage[backend=bibtex,sorting=ynt]{biblatex}    % bibliography
\usepackage{tcolorbox}                               % framed environments
\usepackage{tikz}
\usepackage{xparse}
\usepackage[charter]{mathdesign}                     % changes font
\usepackage[expansion=false,kerning=true]{microtype} % better kerning
\usepackage{enumitem}                                % custom lists
\usepackage{longtable}
\usepackage{array}
\usepackage{totalcount}
\usepackage{standalone}
% setup gitinfo2, as in the manual, details just above begin{document}
\usepackage[mark]{gitinfo2}
% tikz, tcolorbox libraries
\usetikzlibrary{positioning}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations,shapes}
\usepackage{varioref}                                % the documentation library from tcolorbox loads hyperref
\tcbuselibrary{breakable,xparse,documentation,hooks,raster}
\hypersetup{
 pdfauthor={Chris Hughes},
 pdftitle={latexindent.pl package},
 pdfkeywords={perl;beautify;indentation},
 bookmarksnumbered,
 bookmarksopen,
 linktocpage,
 colorlinks=true,
 linkcolor=blue,
 citecolor=black,
}
\usepackage{cleveref}

% create my own star style, for re-use at various points
\tikzset{cmhstar/.style={star,star point ratio=2.25,fill=cmhgold,draw=orange,}}

% shortcut command for displaying star in documentation
\newcommand{\stardemo}[1][]{\begin{tikzpicture}
 \node at (10:.1cm)[very thin,cmhstar,scale=0.25,rotate=20,#1]{};
 \node at (120:.1cm)[very thin,cmhstar,scale=0.15,rotate=-10,#1]{};
 \node at (235:.1cm)[very thin,cmhstar,scale=0.2,rotate=-20,#1]{};
 \end{tikzpicture}}

% totalcount
\DeclareTotalCounter{lstlisting}

% customise the \tcbdocnew command
\tcbset{doclang/new={{\bfseries\color{green!50!black}N\normalfont\color{black}}}}
\tcbset{doclang/updated={{\bfseries\color{green!50!black}U\normalfont\color{black}}}}
\tcbset{doc marginnote={width=1.6cm}}

% \announce * { YYYY-MM-DD }*{ <announcement text> }
%
%   NEW as of current version
%       \announce*{date}*[text] means *updated* as of <date>
%       \announce*{date}[text]  means *new* as of <date>
%
%   NOT new as of current version
%       \announce{date}*[text] means *updated* as of <date>
%       \announce{date}[text]  means *new* as of <date>
%
\NewDocumentCommand{\announce}{ s m s m }{%
 \IfBooleanTF{#1}%
 {% \announce*
  % NEW in current version
  \tcbdocmarginnote[colframe=orange,
   overlay={\node at ([yshift=0mm,xshift=1mm]frame.north east) {\stardemo}; }]{%
   \IfBooleanTF{#3}%
   {% \announce*{date}*[text] means *updated* as of <date>
    \tcbdocupdated{#2}%
   }%
   {% \announce*{date}[text] means *new* as of <date>
    \tcbdocnew{#2}%
   }%
  }%
  \IfBooleanTF{#3}%
  {%
   \addcontentsline{new}{cmhtitle}{#4 (U)}%
  }%
  {%
   \addcontentsline{new}{cmhtitle}{#4 (N)}%
  }%
 }%
 {% \announce
  % NOT new in current version
  \tcbdocmarginnote[colframe=gray!50!white,
   doclang/new={{\color{gray}N\normalfont\color{gray}}},
   doclang/updated={{\color{gray}U\normalfont\color{gray}}},
  ]{%
   \IfBooleanTF{#3}%
   {% \announce{date}*[text] means *updated* as of <date>
    \tcbdocupdated{#2}%
   }%
   {% \announce{date}[text] means *new* as of <date>
    \tcbdocnew{#2}%
   }%
  }%
 }}

\reversemarginpar
% bibliographies
\addbibresource{latex-indent}
\addbibresource{contributors}
\BiblatexSplitbibDefernumbersWarningOff

% http://tex.stackexchange.com/questions/122135/how-to-add-a-png-icon-on-the-right-side-of-a-tcolorbox-title
\newtcolorbox{warning}{parbox=false,
 breakable,
 enhanced,
 arc=0mm,
 colback=red!5,
 colframe=red,
 leftrule=12mm,%
 title={Warning!},
 overlay={\node[anchor=north west,outer sep=2pt] at (frame.north west) {\includegraphics[width=8mm]{warning}}; }
}

\definecolor{harvestgold}{cmyk}{0.00, 0.05, 0.51, 0.07}  %EDE275
\definecolor{cmhgold}{cmyk}{0,0.178,0.909,0.008}         %FDD017
\colorlet{cmhgray}{gray!30!white}

\makeatletter
\tcbset{
 addtolol/.style={list entry={\kvtcb@title},add to list={lol}{lstlisting}},
 addtololstar/.style={list entry={\kvtcb@title},add to list={lol}{lstlistingstar}},
 cmhlistings/.style={
   colback=blue!5!white,
   colframe=white!25!black,colback=white,
   top=0cm,
   bottom=0cm,
   left=0mm,
   listing only,
   center title,
   listing engine=listings,
   listing options={showtabs=true,tabsize=4,showspaces=true},
   boxrule=0pt,
   toprule=1pt,bottomrule=1pt,
   titlerule=1pt,
   colframe=white!40!black,
   colback=white,
   sharp corners,
   colbacktitle=white!75!black
  },
 tex-TCB/.style={
   listing only,
   listing engine=listings,
   left=0cm,
   boxrule=0pt,
   sharp corners,
   center title,
   colframe=white!40!black,
   colback=white,
   sharp corners,
   colbacktitle=white!75!black,
   toprule=1pt,
   bottomrule=1pt,
   titlerule=1pt,
  },
 yaml-TCB/.style={
   listing only,
   listing engine=listings,
   left=0cm,
   boxrule=0pt,
   sharp corners,
   center title,
   colbacktitle=white!75!blue,
   colframe=white!25!blue,
   colback=white!90!blue,
   toprule=2pt,
   titlerule=2pt,
  },
 MLB-TCB/.style={
   yaml-TCB,
   center title,
   colframe=cmhgold,
   colbacktitle=harvestgold,
   colback=white!60!cmhgold,
   width=0.9\linewidth,
   before=\centering,
   enhanced,
   overlay={\node[anchor=north east,outer sep=2pt,draw=cmhgold,very thick,double,fill=harvestgold,font =\small] at ([yshift=-3mm]frame.north east) {\texttt{-m}}; }
  },
 replace-TCB/.style={
   yaml-TCB,
   center title,
   colbacktitle=white!75!green,
   colframe=white!25!green,
   colback=white!90!green,
   width=0.9\linewidth,
   before=\centering,
   enhanced,
   overlay={\node[anchor=north east,outer sep=2pt,draw=white!25!green,very thick,circle,fill=white!75!green,font =\small] at ([yshift=-3mm]frame.north east) {\texttt{-r}}; }
  },
 yaml-obsolete/.style={
   listing only,
   listing engine=listings,
   left=0cm,
   boxrule=0pt,
   sharp corners,
   center title,
   toprule=2pt,
   titlerule=2pt,
   colframe=white!25!red,
   colbacktitle=white!75!red,
   colback=white!90!red,
  },
 new-to-this-version/.style={
   enhanced,
   overlay app={\node at ([yshift=0mm,xshift=0mm]frame.north east) {\stardemo[scale=1.2]}; },
   addtololstar,
  },
}

\DeclareTCBListing[use counter=lstlisting]{cmhlistings}{s O{} m m}{%
 cmhlistings,
 IfBooleanTF={#1}{new-to-this-version}{addtolol},
 center title,
 title={\color{black}{\scshape Listing \thetcbcounter}: ~#3},label={#4},
 listing engine=listings,
 listing options={#2},
}

\DeclareDocumentEnvironment{cmhtcbraster}{O{}}{\begin{tcbraster}[
  new-to-this-version/.style={
    enhanced,
    overlay app={\node[anchor=south east] at ([yshift=-3mm,xshift=3mm]frame.north east) {\stardemo[scale=1.2]}; },
    addtololstar,
   },
  raster valign=top,raster columns=2,#1]}{\end{tcbraster}}

% \cmhlistingsfromfile
%                   * no star: not new, star: new   #1
%                   [ listing options ]             #2
%                   {<name of listing file>}        #3
%                   [<options for tcolorbox>]       #4
%                   {<title>}                       #5
%                   {<label>}                       #6
%
% for example,
%   \cmhlistingsfromfile*[listing options]... is NEW
%   \cmhlistingsfromfile[listing options]...  is not new
\DeclareTCBInputListing[use counter=lstlisting]{\cmhlistingsfromfile}{s O{} m O{} m m}{%
 cmhlistings,
 listing file={#3},
 listing options={style=tcblatex,showspaces=false,#2},
 title={\color{black}{\scshape Listing \thetcbcounter}: ~#5},label={#6},
 #4,
 IfBooleanTF={#1}{new-to-this-version}{addtolol},
}

\makeatletter
\@tempswafalse
\def\@tempa{draft}
\@for\next:=\@classoptionslist\do
{\ifx\next\@tempa\@tempswatrue\fi}
\if@tempswa % draft option is active
 \RenewDocumentCommand{\cmhlistingsfromfile}{s O{} s m O{} m m}{\captionof{lstlisting}{#6}\label{#7}}
 \renewcommand{\stardemo}[1][]{$\star$}
\fi

% command shell
\newtcblisting{commandshell}{colback=black,colupper=white,colframe=yellow!75!black,
 listing only,
 listing options={style=tcblatex,language=sh,
   morekeywords={latexindent,pl},
   keywordstyle=\color{blue!35!white}\bfseries,
  },
 before=\par,
 listing engine=listings,
 left=0cm,
 every listing line={\textcolor{red}{\small\ttfamily\fontseries{b}\selectfont cmh:$\sim$\$ }}}

% dosprompt
\newtcblisting{dosprompt}{
 colback=black,
 colupper=white,
 colframe=yellow!75!black,
 listing only,
 listing options={
   language=command.com,
   morekeywords={latexindent,pl},
   keywordstyle=\color{blue!35!white}\bfseries,
   basicstyle=\small\color{white}\ttfamily
  },
 listing engine=listings,
 left=0cm,
 every listing line={\textcolor{white}{\small\ttfamily\fontseries{b}\selectfont C:\textbackslash Users\textbackslash cmh$>$}}}

\lstset{%
 basicstyle=\small\ttfamily,language={[LaTeX]TeX},
 numberstyle=\ttfamily%\small,
 breaklines=true,
 keywordstyle=\color{blue},                    % keywords
 commentstyle=\color{purple},    % comments
 tabsize=3,
}%
\DeclareTCBListing[use counter=lstlisting]{yaml}{O{} m O{} m}{
 yaml-TCB,
 listing options={
   style=tcblatex,
   numbers=none,
   numberstyle=\color{red},
   #1,
  },
 title={\color{black}{\scshape Listing \thetcbcounter}: ~#2},label={#4},
 #3,
}

% reference: https://tex.stackexchange.com/questions/145504/yaml-syntax-highlighting/654987#654987
\lstdefinestyle{yaml-LST}{
 style=tcblatex,
 numbers=none,
 numberstyle=\color{red}\small,
 basicstyle=\color{black}\ttfamily\small,
 string=[s]{'}{'},
 stringstyle=\color{black}\ttfamily\small,
 comment=[l]{:},
 commentstyle=\color{blue}\ttfamily\small,
 morecomment=[l]{-},
}

\lstdefinestyle{demo}{
 numbers=none,
 linewidth=1.25\textwidth,
 columns=fullflexible,
}

\lstdefinestyle{lineNumbersTeX}{
 numbers=left,
 numberstyle=\color{blue},
}

\lstdefinestyle{fileExtensionPreference}{
 style=yaml-LST,
 firstnumber=47,linerange={47-51},
 numbers=left,
}

\lstdefinestyle{logFilePreferences}{
 style=yaml-LST,
 firstnumber=90,linerange={90-104},
 numbers=left,
}

\lstdefinestyle{verbatimEnvironments}{
 style=yaml-LST,
 firstnumber=108,linerange={108-111},
 numbers=left,
}

\lstdefinestyle{verbatimCommands}{
 style=yaml-LST,
 firstnumber=114,linerange={114-116},
 numbers=left,
}

\lstdefinestyle{noIndentBlock}{
 style=yaml-LST,
 firstnumber=121,linerange={121-123},
 numbers=left,
}

\lstdefinestyle{removeTrailingWhitespace}{
 style=yaml-LST,
 firstnumber=153,linerange={153-155},
 numbers=left,
}

\lstdefinestyle{fileContentsEnvironments}{
 style=yaml-LST,
 firstnumber=127,linerange={127-129},
 numbers=left,
}

\lstdefinestyle{lookForPreamble}{
 style=yaml-LST,
 firstnumber=135,linerange={135-140},
 numbers=left,
}

\lstdefinestyle{lookForAlignDelims}{
 style=yaml-LST,
 firstnumber=158,linerange={158-177},
 numbers=left,
}

\lstdefinestyle{indentAfterItems}{
 style=yaml-LST,
 firstnumber=242,linerange={242-249},
 numbers=left,
}

\lstdefinestyle{itemNames}{
 style=yaml-LST,
 firstnumber=255,linerange={255-257},
 numbers=left,
}

\lstdefinestyle{specialBeginEnd}{
 style=yaml-LST,
 firstnumber=261,linerange={261-275},
 numbers=left,
}

\lstdefinestyle{indentAfterHeadings}{
 style=yaml-LST,
 firstnumber=285,linerange={285-294},
 numbers=left,
}

\lstdefinestyle{noAdditionalIndentGlobalEnv}{
 style=yaml-LST,
 firstnumber=343,linerange={343-344},
 numbers=left,
}

\lstdefinestyle{noAdditionalIndentGlobal}{
 style=yaml-LST,
 firstnumber=343,linerange={343-355},
 numbers=left,
}

\lstdefinestyle{indentRulesGlobalEnv}{
 style=yaml-LST,
 firstnumber=359,linerange={359-360},
 numbers=left,
}

\lstdefinestyle{indentRulesGlobal}{
 style=yaml-LST,
 firstnumber=359,linerange={359-371},
 numbers=left,
}

\lstdefinestyle{commandCodeBlocks}{
 style=yaml-LST,
 firstnumber=374,linerange={374-389},
 numbers=left,
}

\lstdefinestyle{modifylinebreaks}{
 style=yaml-LST,
 firstnumber=502,linerange={502-504},
 numbers=left,
}

\lstdefinestyle{textWrapOptions}{
 style=yaml-LST,
 firstnumber=532,linerange={532-533},
 numbers=left,
}

\lstdefinestyle{textWrapOptionsAll}{
 style=yaml-LST,
 firstnumber=532,linerange={532-559},
 numbers=left,
}

\lstdefinestyle{oneSentencePerLine}{
 style=yaml-LST,
 firstnumber=505,linerange={505-531},
 numbers=left,
}

\lstdefinestyle{sentencesFollow}{
 style=yaml-LST,
 firstnumber=511,linerange={511-519},
 numbers=left,
}

\lstdefinestyle{sentencesBeginWith}{
 style=yaml-LST,
 firstnumber=520,linerange={520-523},
 numbers=left,
}

\lstdefinestyle{sentencesEndWith}{
 style=yaml-LST,
 firstnumber=524,linerange={524-529},
 numbers=left,
}

\lstdefinestyle{sentencesDoNOTcontain}{
 style=yaml-LST,
 firstnumber=530,linerange={530-531},
 numbers=left,
}

\lstdefinestyle{modifylinebreaksEnv}{
 style=yaml-LST,
 firstnumber=561,linerange={561-570},
 numbers=left,
}

\lstdefinestyle{replacements}{
 style=yaml-LST,
 firstnumber=622,linerange={622-627},
 numbers=left,
}

\lstdefinestyle{fineTuning}{
 style=yaml-LST,
 firstnumber=631,linerange={631-686},
 numbers=left,
}

% stars around contributors
\pgfdeclaredecoration{stars}{initial}{
 \state{initial}[width=15pt]
 {
  \pgfmathparse{round(rnd*100)}
  \pgfsetfillcolor{yellow!\pgfmathresult!orange}
  \pgfsetstrokecolor{yellow!\pgfmathresult!red}
  \pgfnode{star}{center}{}{}{\pgfusepath{stroke,fill}}
 }
 \state{final}
 {
  \pgfpathmoveto{\pgfpointdecoratedpathlast}
 }
}

\newtcolorbox{stars}{%
 enhanced jigsaw,
 breakable, % allow page breaks
 left=0cm,
 top=0cm,
 before skip=0.2cm,
 boxsep=0cm,
 frame style={draw=none,fill=none}, % hide the default frame
 colback=white,
 overlay={
   \draw[inner sep=0,minimum size=rnd*15pt+2pt]
   decorate[decoration={stars,segment length=2cm}] {
     decorate[decoration={zigzag,segment length=2cm,amplitude=0.3cm}] {
       ([xshift=-.5cm,yshift=0.1cm]frame.south west) -- ([xshift=-.5cm,yshift=0.4cm]frame.north west)
      }};
   \draw[inner sep=0,minimum size=rnd*15pt+2pt]
   decorate[decoration={stars,segment length=2cm}] {
     decorate[decoration={zigzag,segment length=2cm,amplitude=0.3cm}] {
       ([xshift=.75cm,yshift=0.1cm]frame.south east) -- ([xshift=.75cm,yshift=0.6cm]frame.north east)
      }};
   \node[anchor=north west,outer sep=2pt,opacity=0.25] at ([xshift=-4.25cm]frame.north west) {\resizebox{3cm}{!}{\faGithub}};
  },
 % paragraph skips obeyed within tcolorbox
 parbox=false,
}

\newtcolorbox[auto counter]{example}{breakable,
 enhanced jigsaw,
 before skip balanced,
 after skip balanced,
 frame hidden,
 %
 % title stuff
 %
 title={example~\thetcbcounter},
 fonttitle=\bfseries\sffamily,
 detach title,
 coltitle=black,
 colback=white,
 grow to left by=6mm,
 %
 % circles and line by the side
 %
 overlay unbroken and first={%
   \node at ([xshift=-8mm,yshift=-4.5mm]interior.north west) {\bfseries example \thetcbcounter};
   \path [fill=black] ([xshift=1mm,yshift=3mm]interior.south east) node{\hbox{\rule{1ex}{1ex}}};
  },
 overlay last={%
   \path [fill=black] ([xshift=1mm,yshift=3mm]interior.south east) node{\hbox{\rule{1ex}{1ex}}};
  },
 parbox=false,
}

% copied from /usr/local/texlive/2013/texmf-dist/tex/latex/biblatex/bbx/numeric.bbx
% the only modification is the \stars and \endstars
\defbibenvironment{specialbib}
{\stars\list
 {\printtext[labelnumberwidth]{%
   \printfield{prefixnumber}%
   \printfield{labelnumber}}}
 {\setlength{\labelwidth}{\labelnumberwidth}%
  \setlength{\leftmargin}{\labelwidth}%
  \setlength{\labelsep}{\biblabelsep}%
  \addtolength{\leftmargin}{\labelsep}%
  \setlength{\itemsep}{\bibitemsep}%
  \setlength{\parsep}{\bibparsep}}%
 \renewcommand*{\makelabel}[1]{\hss##1}}
{\endlist\endstars}
{\item}

\newcommand{\flagbox}[1]{%
 \par
 \makebox[30pt][l]{%
  \hspace{-1cm}%
  \ttfamily\fontseries{b}\selectfont #1
 }%
}

\NewDocumentCommand{\yamltitle}{O{} m s m}{%
 \par
 \makebox[30pt][l]{%
  \hspace{-2cm}%
  \tcbox[colframe=black!50!white,boxrule=.5pt,sharp corners,#1]{%
   {\ttfamily\fontseries{b}\selectfont{\color{blue!80!white}#2}}: %
   \IfBooleanTF{#3}
   {$\langle$\itshape #4$\rangle$}
   {{\bfseries #4}}
  }}
 \par\nobreak%
}

\newcommand{\fixthis}[1]
{%
 \marginpar{\huge \color{red} \framebox{FIX}}%
 \typeout{FIXTHIS: p\thepage : #1^^J}%
}

\newcommand*\ruleline[1]{%
 \par\noindent\raisebox{.8ex}{\makebox[\linewidth]{\hrulefill\hspace{1ex}\raisebox{-1.8ex}{#1}\hspace{1ex}\hrulefill}}}

\newcommand{\imagetouse}{logo-bw}

% custom section
\titleformat% Formatting the header
{\section} % command
[block] % shape - Only managed to get it working with block
{\normalfont\bfseries\huge} % format - Change here as needed
{\centering {\scshape Section \thesection}\\} % the section
{0pt} % sep
{\centering \ruleline{\includegraphics{\imagetouse}}\\ % The horizontal rule
 \centering} % And the actual title

% custom subsection
\titleformat{\subsection}
{\normalfont\bfseries}
{\llap{\thesubsection\hskip.5cm}}
{0pt}
{}

% custom subsubsection
\titleformat{\subsubsection}
{\normalfont\bfseries}
{\llap{\thesubsubsection\hskip.5cm}}
{0pt}
{}

% custom paragraph
\titleformat{\paragraph}
{\normalfont\bfseries}
{\llap{\theparagraph\hskip.5cm}}
{0pt}
{}

% title spacing
\titlespacing\section{0pt}{12pt plus 4pt minus 2pt}{34pt plus 2pt minus 2pt}
\titlespacing\subsection{0pt}{12pt plus 4pt minus 2pt}{4pt plus 2pt minus 2pt}
\titlespacing\subsubsection{0pt}{12pt plus 4pt minus 2pt}{4pt plus 2pt minus 2pt}
\titlespacing\paragraph{0pt}{12pt plus 4pt minus 2pt}{4pt plus 2pt minus 2pt}

% list of listings
\contentsuse{lstlisting}{lol}
\titleclass{\lstlistingstar}{straight}[\section]
\titleformat{\lstlistingstar}{}{}{}{}
\titlecontents{lstlistingstar}[2em]
  {\addvspace{0.25pc}}
  {}
  {\llap{\stardemo}\thecontentslabel}
  {\titlerule*[0.5em]{$\cdot$}\contentspage}
  []
\titlecontents{lstlisting}[2em]
  {\addvspace{0.25pc}}
  {\thecontentslabel}
  {\thecontentslabel}
  {\titlerule*[0.5em]{$\cdot$}\contentspage}
  []
\AtBeginDocument{\addtocontents{lol}{\protect\begin{widepage}\protect\begin{multicols}{2}}}
\preto{\printindex}{\addtocontents{lol}{\protect\end{multicols}\protect\end{widepage}}}

% cleveref settings
\crefname{table}{Table}{Tables}
\Crefname{table}{Table}{Tables}
\crefname{figure}{Figure}{Figures}
\Crefname{figure}{Figure}{Figures}
\crefname{section}{Section}{Sections}
\Crefname{section}{Section}{Sections}
\crefname{listing}{Listing}{Listings}
\Crefname{listing}{Listing}{Listings}

% headers and footers
\fancyhf{} % delete current header and footer
\fancyhead[R]{\bfseries\thepage%
 \tikz[remember picture,overlay] {
  \node at (1,0){\includegraphics{logo-bw}}; }
}
\fancyhead[L]{\rightmark}
\fancyheadoffset[L]{3cm}
\pagestyle{fancy}

% renew plain style
\fancypagestyle{plain}{%
 \fancyhf{} % clear all header and footer fields
 \renewcommand{\headrulewidth}{0pt}
 \renewcommand{\footrulewidth}{0pt}}

% widepage environment
\newenvironment{widepage}{\begin{adjustwidth}{-3cm}{0cm}}{\end{adjustwidth}}

% symbols for the m switch
\newcommand{\BeginStartsOnOwnLine}{\color{red}\spadesuit}
\newcommand{\BodyStartsOnOwnLine}{\color{red}\heartsuit}
\newcommand{\EndStartsOnOwnLine}{\color{red}\diamondsuit}
\newcommand{\EndFinishesWithLineBreak}{\color{red}\clubsuit}
\newcommand{\ElseStartsOnOwnLine}{\color{red}\bigstar}
\newcommand{\ElseFinishesWithLineBreak}{\color{red}\square}
\newcommand{\OrStartsOnOwnLine}{\color{red}\blacktriangle}
\newcommand{\OrFinishesWithLineBreak}{\color{red}\blacktriangledown}
\newcommand{\EqualsStartsOnOwnLine}{\color{red}\bullet}

% table rules
\setlength\heavyrulewidth{0.25ex}
% gitinfo2 settings
\renewcommand{\gitMark}{\gitBranch\,@\,\gitAbbrevHash{}\,\textbullet{}\,\gitAuthorDate\,\textbullet{}\faGithub\,\textbullet{}\gitRel}

% setting up gitinfo2:
%   copy the file post-xxx-sample.txt from http://mirror.ctan.org/macros/latex/contrib/gitinfo2
%   and put it in .git/hooks/post-checkout
% then
%   cd .git/hooks
%   chmod g+x post-checkout
%   chmod +x post-checkout
%   cp post-checkout post-commit
%   cp post-checkout post-merge
%   cd ../..
%   git checkout master
%   git checkout develop
%   ls .git
% and you should see gitHeadInfo.gin
% 
% Make sure that the 'V' is included in the below!
%
% RELTAG=$(git describe --tags --long --always --dirty='-*' --match 'V[0-9]*.*' 2>/dev/null)

% http://tex.stackexchange.com/questions/233843/textasteriskcentered-invisible-with-garamondmathdesign
% remove the definition of \textasteriskcentered for TS1 encoding
\UndeclareTextCommand{\textasteriskcentered}{TS1}
% reinstate a default encoding
\DeclareTextSymbolDefault{\textasteriskcentered}{OT1}
% suitably define the command
\DeclareTextCommand{\textasteriskcentered}{OT1}{\raisebox{-.7ex}[1ex][0pt]{*}}

% new features list
\newcommand{\listOfNewFeatures}{\setcounter{tocdepth}{4}\@starttoc{new}}
\contentsuse{cmhtitle}{new}
% toc settings
\titleclass{\cmhtitle}{straight}[\subsection]
\titleformat{\cmhtitle}{}{}{}{}
\titlecontents{cmhtitle}% <paragraph>
  [2cm]% <left>
  {\small\itshape}% <above-code>
  {}% <numbered-entry-format>; you could also use {\thecontentslabel. } to show the numbers
  {}% <numberless-entry-format>
  {\titlerule*[0.5em]{$\cdot$}\contentspage}

% to explore in the future: 
%   partial toc customisation
%   https://tex.stackexchange.com/questions/66345/how-to-remove-section-indentation-in-partial-toc-using-titletoc

\setcounter{secnumdepth}{6}
\setcounter{tocdepth}{4}
\makeindex

\newif\iftestdefaultsettings
\testdefaultsettingsfalse
%\testdefaultsettingstrue

\begin{document}
\renewcommand*{\thefootnote}{\arabic{footnote}}
\input{title}
\tableofcontents
% start sections on new page
\newcommand{\sectionbreak}{\clearpage\thispagestyle{plain}}
 \iftestdefaultsettings
 \input{test-default-settings}
 \input{sec-references}
 \else
 \input{sec-introduction}
 \input{sec-demonstration}
 \input{sec-how-to-use}
 \input{sec-indent-config-and-settings}
 \input{sec-default-user-local}
 \input{subsec-noAdditionalIndent-indentRules}
 \input{subsubsec-environments-and-their-arguments}
 \input{subsubsec-environments-with-items}
 \input{subsubsec-commands-with-arguments}
 \input{subsubsec-ifelsefi}
 \input{subsubsec-special}
 \input{subsubsec-headings}
 \input{subsubsec-no-add-remaining-code-blocks}
 \stopcontents[noAdditionalIndent]
 \input{subsec-commands-and-their-options}
 \input{sec-the-m-switch}
 \input{subsec-text-wrap}
 \input{subsec-one-sentence-per-line}
 \input{subsec-poly-switches}
 \stopcontents[the-m-switch]
 \input{sec-replacements}
 \input{sec-the-line-switch}
 \input{sec-fine-tuning}
 \input{sec-conclusions-know-limitations}
 \input{sec-references}
 \input{sec-appendices}
 {\clearpage\addcontentsline{toc}{section}{List of listings}\small\lstlistoflistings}
 \printindex
 \fi
\end{document}
